FE-1583: Run the connected optimizer's trials through the experiments backend - #9516
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
06f4f63 to
9dfc3eb
Compare
fe9bfc0 to
2f1fd14
Compare
2f1fd14 to
dc659ba
Compare
dc659ba to
fc5cf7b
Compare
5e0c960 to
ed68423
Compare
PR SummaryHigh Risk Overview The experiments layer gains The optimizations stack wires a channel that maps each optimizer trial to one detached run (objective from per-run means or last frames; failures become pruned trials).
Reviewed by Cursor Bugbot for commit b058535. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
🟡 Changes recommended
Surface caching, best-point refinement, user documentation, and package changesets contain unresolved correctness issues.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds experimental in-browser optimization to Petrinaut, routing optimizer trials through the experiments backend with streaming, refinement, navigation, and continuation support.
Changes:
- Adds connected optimizer lifecycle, feature gating, detached objective execution, and refinement.
- Introduces connected-study UI, shared experiment components, and surface visualization enhancements.
- Adds the Vaccination Campaign example, tests, stories, documentation, and package changeset.
File summaries
| File | Description |
|---|---|
viewport-settings-dialog.tsx |
Adds the experimental setting. |
viewport-settings-dialog.test.tsx |
Tests its default value. |
simulate-view.tsx |
Gates connected optimization UI. |
simulate-view.test.tsx |
Tests optimization tab gating. |
use-gpu-availability.ts |
Extracts GPU eligibility analysis. |
surface-frame.tsx |
Generalizes surface captions. |
summary-strip.tsx |
Adds shared summary presentation. |
metric-tiles.tsx |
Extracts reusable metric tiles. |
format-value.ts |
Centralizes value formatting. |
compute-backend-toggle.tsx |
Adds shared backend selection UI. |
compute-backend-badge.tsx |
Adds shared backend status UI. |
compute-activity.tsx |
Generalizes compute progress display. |
study-summary-strip.tsx |
Summarizes connected study progress. |
study-summary-strip.test.ts |
Tests step-progress descriptions. |
steps-table.tsx |
Displays recent optimization steps. |
study-progress.ts |
Derives study progress and activity. |
optimization-navigator.tsx |
Adds connected parameter navigation. |
optimization-metrics.tsx |
Displays streamed objective metrics. |
navigator-band.tsx |
Composes connected navigation controls. |
continue-control.tsx |
Adds study continuation controls. |
view-optimization-drawer.stories.tsx |
Adds drawer variants. |
optimizations-view.tsx |
Reuses shared formatting and statuses. |
use-study-surface-walk.ts |
Samples remote study surfaces. |
sample-study-cell.ts |
Caches and samples surface cells. |
navigation-slice.ts |
Resolves surface slices and keys. |
optimization-surface.stories.tsx |
Adds connected surface stories. |
optimization-status.ts |
Distinguishes stopped connected studies. |
optimization-seed.ts |
Generates and validates study seeds. |
browser-optimizer.stories.tsx |
Adds real browser optimizer stories. |
experiment-metrics.tsx |
Adopts shared metric tiles. |
view-experiment-drawer.tsx |
Adopts the shared backend badge. |
sweep-surface.tsx |
Uses generalized surface APIs. |
experiments/shared/format-number.ts |
Removes superseded formatter. |
experiments-story-fixtures.tsx |
Adds streaming objective fixtures. |
bin-histogram-canvas.tsx |
Uses shared fixed formatting. |
frame-popover.tsx |
Uses shared fixed formatting. |
experiment-metric-timeline.tsx |
Supports fixed-size metric charts. |
create-experiment-drawer.tsx |
Reuses shared GPU controls. |
create-experiment-drawer.test.tsx |
Updates provider fixtures. |
editor-view.tsx |
Lists the new example. |
paint-field.ts |
Adds marker variants and sparse-field behavior. |
contour-field.test.ts |
Tests irregular sparse interpolation. |
contour-surface.tsx |
Supports display-only plots and marker options. |
user-settings-provider.tsx |
Persists the new feature flag. |
user-settings-context.ts |
Defines the feature setting. |
use-optimization-source.ts |
Centralizes source gating. |
surface-grid.ts |
Adds navigation key/value helpers. |
sir-optimization-input.fixtures.ts |
Adds shared SIR test input. |
objective-estimate.ts |
Estimates objective uncertainty. |
objective-estimate.test.ts |
Tests refinement stopping logic. |
point-refinement.ts |
Implements the refinement ladder. |
fake-detached-objective-runs.fixtures.ts |
Adds controllable run fixtures. |
optimizations/context.ts |
Expands connected study state and actions. |
trial-outcome.ts |
Converts experiment outcomes to trial outcomes. |
create-optimization-channel.ts |
Connects trials to experiment runs. |
create-optimization-channel.test.ts |
Tests channel execution behavior. |
optimization-context.ts |
Accepts connected optimization sources. |
react/index.ts |
Exports connected optimization APIs. |
sweep-session/README.md |
Updates shared-module architecture. |
sweep-session/batch-registry.ts |
Removes the old private registry. |
sweep-session/batch-registry.test.ts |
Removes superseded tests. |
sweep-session.ts |
Adopts the shared registry and throttle. |
shared/throttle.ts |
Adds reusable throttling. |
shared/error-message.ts |
Adds shared error normalization. |
shared/batch-registry.ts |
Adds the generic batch registry. |
shared/batch-registry.test.ts |
Tests generic registry behavior. |
experiments/provider.tsx |
Exposes streaming detached runs. |
experiments/context.ts |
Defines detached run contracts. |
main.ts |
Exports connected optimization types. |
docs/examples.md |
Documents Vaccination Campaign. |
compilation-report.test.ts |
Includes the new GPU-ready example. |
vaccination-campaign.test.ts |
Tests example behavior and eligibility. |
examples/index.ts |
Exports Vaccination Campaign. |
examples.test.ts |
Adds the example to validation tests. |
ai.ts |
Adds the example to documentation summaries. |
Slider/slider.tsx |
Adds disabled slider support. |
.changeset/connected-optimizer-source.md |
Records consumer-facing changes. |
Review details
- Files reviewed: 96/97 changed files
- Comments generated: 4
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…orker kept A worker crash or a study error settles the run, but the host's trial evaluations kept a live signal and simulated on for outcomes no one would read. Every terminal event now aborts the segment's controller. A crash also took the studies kept for finished runs with it, so a later continuation started a fresh worker only to fail with study_failed; those runs now lose their resumable status and the continuation is refused with the reason.
A host had no way to tell a stopped study the worker kept from a first segment cancelled before it reached the worker, so it offered Continue for studies that were never created and the extension was refused. Terminal events now carry `resumable`: true when the study stays in the worker, false when the run failed or its segment never started. A remote service omits it.
…behind an experimental setting
…hart stay in view
The study seed masks a 32-bit crypto draw instead of reducing it modulo the range. Stop on a connected study whose run has no id yet aborts the creation so its run is cancelled where it was made. A point stopped early as unable to beat the best resumes its ladder once it is the best. The surface cell cache keys on the axes as well as the positions, so swapped axes never reuse each other's samples. Changesets are one per package, with one for the Vaccination Campaign example in petrinaut-core.
A cancelled terminal marked every connected study resumable while its local study object existed, so a first segment stopped before it reached the worker, as while the runtime loads or another study holds the worker, showed Continue and then had its extension refused. The record's resumable flag now follows the terminal event's, which the runtime sets from whether the study exists.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b6ce53. Configure here.
The refinement restarts when a point's isBest changes, but nothing asked it to once the study had parked: a trial landing on the parked point and becoming the best left the point stopped at its early-stop note. The connected study now compares the best point's key before and after each trial event and, while the navigation is parked, refines the point again; settling does the same for a parked point instead of only settling a following study.

Important
Experimental
Behind the In-browser optimization feature flag.
Summary
Before this PR,
PetrinautOptimizationContextaccepted a self-contained remote capability, and a study's trials were numbers in a table. Study drawer's Surface could sample the objective locally, but it knew nothing of where the optimizer was looking, and the optimizer could not use the browser's compute at all.This PR lets the context carry a connected optimization source and runs its trials through the experiments layer. A new
runDetachedObjectiveaction runs a frozen study's objective at one parameter point on the chosen backend with pinned seeds and streams its frames. Optimizations provider evaluates each trial through it, follows the trial in the navigator, streams its metrics live, and after the study settles refines the best point, or whichever point the user picks. Study drawer shows the optimizer's own steps as dots on the Surface with the field filling in as steps report, a Stop that keeps the study and a Continue that adds steps to it, up to four steps in flight with an activity list, and one metric line always in view. Form gains Runs per step, Parallel steps and the experiments' Backend switch. A remote capability such as the HASH host's NodeAPI bridge is unaffected, and the connected source only takes effect with the experimental setting on.9516.mp4
Links
Changes
Feature flag
useOptimizationSourceis the one place that reads the context and the settingExperiments layer
runDetachedObjectiveruns a study's objective at one point and streams itqueueKeywhile sharing one compiled snapshot percacheKeyexperiments/sharedfor reuseOptimization channel and provider
computeBackend, the study'saxesand, for a connected study only, aconnectedstate with itsnavigation,selectionstream,activity,inFlighttrials,resumable,parallelismand fallback reasonextendOptimization(id, steps)continues a finished or stopped connected studyForm and drawer
react.optimizations.connected-studyandui.views.editor.optimizationsdeclare the study machinery and the Optimizations tab in the architecture docsSimulateView/shared:useGpuAvailability,ComputeBackendToggle,ComputeBackendBadge,MetricTiles,ComputeActivity,SummaryStrip,format-valueSliderin@hashintel/ds-componentsacceptsdisabledStories and example
Simulate / Browser optimizer (real)runs the real Pyodide optimizer against the real experiments backendsReview fixes
resumableflagKnown issues
Test coverage
provider/detached-objective.test.ts:optimizations/provider.test.tsx,provider/connected-study.test.ts,provider/point-refinement.test.ts,provider/point-refinement/objective-estimate.test.ts,provider/activity-registry.test.ts,channel/create-optimization-channel.test.ts:create-optimization-drawer.test.tsx,view-optimization-drawer.test.tsx,study-summary-strip.test.ts,steps-table.test.ts,optimization-navigator.test.tsx,optimization-surface/surface-plot.test.tsx,simulate-view.test.tsx,viewport-settings-dialog.test.tsx:examples/vaccination-campaign.test.ts,webgpu/compilation-report.test.ts:How to test
yarn workspace @hashintel/petrinaut dev